package org.example.day20240830正则;

public class Main1 {
    public static void main(String[] args) {
        String[] msg = {"fuck","sb","shit","shacha"};
        String comment = "desk is a word so big shit fuck sh shacha";
        String[] change = {"****","**","****","******"};
        String[] str = comment.split(" ");
        String result = "";
        StringBuffer stringBuffer = new StringBuffer(result);
        for(int i=0; i<msg.length; i++){
            for (int j=0; j<str.length; j++){
                if(str[j].equals(msg[i])){
                    str[j] = str[j].replace(msg[i],change[i]);
                }
            }
        }
        for (int i=0; i<str.length; i++){
            stringBuffer.append(str[i]);
            stringBuffer.append(" ");
        }
        System.out.println(stringBuffer);
    }

}
